﻿<Window x:Class="Wpf2.Views.FormEditBeforePrintOutInventory"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="Xuất kho - Sửa trước khi in" Width="Auto" Height="597.015"  WindowStartupLocation="CenterScreen" WindowState="Maximized">
    <StackPanel  Background="#FF3C2AF9" Margin="0,0,0,4">
        
        <StackPanel Margin="10,10,10,0" Height="50" >
            <StackPanel  Orientation="Horizontal" Background="{DynamicResource {x:Static SystemColors.ControlBrushKey}}">
                <Label Height="30" Content="Tên cửa hàng"></Label>
                <TextBox Name="txtStoreName" Text="KHANG HUY" TextWrapping="Wrap" VerticalScrollBarVisibility="Auto" 
         AcceptsReturn="True" Width="76" Height="20" Margin="0,15" ></TextBox>
                <Label Height="30" Content="Địa chỉ" Margin="20,0,0,0"></Label>
                <TextBox Name="txtAddress" Width="179" Height="20" Text="667 CMT8, KP2, Thị Xã Tây Ninh" Margin="0,15"></TextBox>
                <Label Height="30" Content="Di động" Margin="20,0,0,0"></Label>
                <TextBox Name="txtMobile" Width="78" Height="20" Text="0982777728" Margin="0,15" ></TextBox>
                <Label Height="30" Content="Điện thoại" Margin="20,0,0,0"></Label>
                <TextBox Name="txtPhone" Width="86" Height="20" Text="(066)2220333" Margin="0,15"></TextBox>
                <StackPanel Margin="20,0,20,0" HorizontalAlignment="Right"  Width="120" Height="30" Orientation="Horizontal">
                    <Button x:Name="btnPrint" Click="BtnPrintClick"  Width="90" Background="#16499A">
                        <TextBlock Foreground="#FFFCFCFC"> In</TextBlock>
                    </Button>
                    <StackPanel Width="30" Height="30" Background="#FF0050EF">
                        <Image Source="/Wpf2;component/Images/print.png" OpacityMask="#FF0050EF" />
                    </StackPanel>
                </StackPanel>
            </StackPanel>
        </StackPanel>
        <StackPanel Orientation="Vertical">
            <DataGrid x:Name="dtgInventory" ItemsSource="{Binding}" Background="White"  Height="374" AutoGenerateColumns="False" CanUserAddRows="False" Margin="10,10,10,0" AlternatingRowBackground="PaleTurquoise" VerticalAlignment="Top">
                <DataGrid.RowHeaderTemplate>
                    <DataTemplate>
                        <TextBlock  Width="20" Text="{Binding Header, RelativeSource={RelativeSource AncestorType={x:Type DataGridRow}, Mode=FindAncestor}}"/>
                    </DataTemplate>
                </DataGrid.RowHeaderTemplate>
                <DataGrid.Columns>
                    <DataGridTemplateColumn Header="Mã SP" Width="auto">
                        <DataGridTemplateColumn.CellTemplate>
                            <DataTemplate>
                                <Grid VerticalAlignment="Bottom" HorizontalAlignment="Center">
                                    <TextBox Height="20" Width="80" Text="{Binding ProductId, UpdateSourceTrigger=PropertyChanged}" BorderThickness="0" Background="{x:Null}"/>
                                </Grid>
                            </DataTemplate>
                        </DataGridTemplateColumn.CellTemplate>
                    </DataGridTemplateColumn>
                    <DataGridTemplateColumn Header="Tên Sản Phẩm" Width="100">
                        <DataGridTemplateColumn.CellTemplate>
                            <DataTemplate>
                                <Grid VerticalAlignment="Bottom" HorizontalAlignment="Center">
                                    <TextBox Height="20" Width="100" Text="{Binding ProductName, UpdateSourceTrigger=PropertyChanged}" BorderThickness="0" Background="{x:Null}"/>
                                </Grid>
                            </DataTemplate>
                        </DataGridTemplateColumn.CellTemplate>
                    </DataGridTemplateColumn>
                    <DataGridTemplateColumn Header="Mô Tả" Width="100">
                        <DataGridTemplateColumn.CellTemplate>
                            <DataTemplate>
                                <Grid VerticalAlignment="Bottom" HorizontalAlignment="Center">
                                    <TextBox Height="20" Width="100" Text="{Binding ProductDescription, UpdateSourceTrigger=PropertyChanged}" BorderThickness="0" Background="{x:Null}"/>
                                </Grid>
                            </DataTemplate>
                        </DataGridTemplateColumn.CellTemplate>
                    </DataGridTemplateColumn>

                    <!-- BeginRegion-->
                    <!-- DataGird không thể sử dụng elementName => phải dùng Source-->
                    <!-- hiện lỗi không sao! cứ bỏ qua-->
                    <!-- Xử lý dạng Đá Hoa Cương (9/5/2014)-->
                    <DataGridTemplateColumn Header="Dài" Width="50" IsReadOnly="True" CanUserSort="False">
                        <DataGridTemplateColumn.CellTemplate>
                            <DataTemplate>
                                <TextBox Text="{Binding ProductHeight, UpdateSourceTrigger=LostFocus}" TextChanged="CaculationPayment" BorderThickness="0"  Background="{x:Null}"></TextBox>
                            </DataTemplate>
                        </DataGridTemplateColumn.CellTemplate>
                    </DataGridTemplateColumn>
                    <DataGridTemplateColumn Header="Rộng" Width="50" IsReadOnly="True" CanUserSort="False">
                        <DataGridTemplateColumn.CellTemplate>
                            <DataTemplate>
                                <TextBox Text="{Binding ProductWidth, UpdateSourceTrigger=LostFocus}" TextChanged="CaculationPayment" BorderThickness="0" Background="{x:Null}"></TextBox>
                            </DataTemplate>
                        </DataGridTemplateColumn.CellTemplate>
                    </DataGridTemplateColumn>
                    <!-- EndRegion-->
                    <DataGridTemplateColumn Header="Số Lượng" Width="50">
                        <DataGridTemplateColumn.CellTemplate>
                            <DataTemplate>
                                <TextBox Text="{Binding InventoryCount, UpdateSourceTrigger=PropertyChanged}" PreviewTextInput="IsAcceptNumberic" BorderThickness="0" TextChanged="TxtInventoryCountTextChanged" Background="{x:Null}"></TextBox>
                            </DataTemplate>
                        </DataGridTemplateColumn.CellTemplate>
                    </DataGridTemplateColumn>
                    <!-- Chức năng Đá Hoa Cương: thêm ngày (9/5/14)-->
                    <DataGridTextColumn Header="M2" Binding="{Binding ProductM2, UpdateSourceTrigger=PropertyChanged}" Width="80" IsReadOnly="True" CanUserSort="False"/>
                    <DataGridTemplateColumn Header="Giá" Width="80">
                        <DataGridTemplateColumn.CellTemplate>
                            <DataTemplate>
                                <TextBox Text="{Binding Price, UpdateSourceTrigger=PropertyChanged,StringFormat={}\{0:###\,##0\}}" PreviewTextInput="IsAcceptNumberic" BorderThickness="0" TextChanged="TxtInventoryCountTextChanged" Background="{x:Null}"></TextBox>
                            </DataTemplate>
                        </DataGridTemplateColumn.CellTemplate>
                    </DataGridTemplateColumn>
                    <DataGridTemplateColumn Header="Đơn vị" Width="80">
                        <DataGridTemplateColumn.CellTemplate>
                            <DataTemplate>
                                <TextBox Text="{Binding UnitName, UpdateSourceTrigger=PropertyChanged}" BorderThickness="0" Background="{x:Null}"></TextBox>
                            </DataTemplate>
                        </DataGridTemplateColumn.CellTemplate>
                    </DataGridTemplateColumn>
                    <DataGridTextColumn Header="Thành tiền" Binding="{Binding TotalOutPayment, UpdateSourceTrigger=PropertyChanged,StringFormat={}\{0:###\,##0\}}" IsReadOnly="True" Width="100" CanUserSort="False"/>
                    <DataGridTemplateColumn Header="Nhóm" Width="*">
                        <DataGridTemplateColumn.CellTemplate>
                            <DataTemplate>
                                <TextBox Text="{Binding CatalogName, UpdateSourceTrigger=PropertyChanged}" BorderThickness="0" KeyDown="KeyDownExcuteAddNewRow" Background="{x:Null}"></TextBox>
                            </DataTemplate>
                        </DataGridTemplateColumn.CellTemplate>
                    </DataGridTemplateColumn>
                </DataGrid.Columns>
            </DataGrid>
        </StackPanel>
        <StackPanel Height="100"  Orientation="Horizontal" Background="#FFF6F6F6" x:Name="panelOfPaymentInfomation" Margin="10,10,10,0" HorizontalAlignment="Right">
            <StackPanel Margin="900,10,10,10">
                <WrapPanel HorizontalAlignment="Right" Margin="0,0,0,10">
                    <Label Width="80" Height="30" Target="{Binding ElementName=txtOLD_DEBTS}" Content="_Nợ cũ:" Background="#FF0050EF" Foreground="#FFFCFCFC" />
                    <TextBox Height="30" x:Name="txtOLD_DEBTS" Text="{Binding OldDebts, StringFormat=\{0:###\,##0\}, UpdateSourceTrigger=PropertyChanged}" TextAlignment="Right"  Width="130" Margin="0,0,0,0" PreviewTextInput="IsAcceptNumberic" Background="#FF0050EF" Foreground="#FFFCFCFC"/>
                </WrapPanel>
                <WrapPanel HorizontalAlignment="Right" >
                    <Label Width="80" Height="30" Target="{Binding ElementName=txtPRE_PAID}" Content="_Gửi trước:" Background="#FF0050EF" Foreground="#FFFCFCFC"/>
                    <TextBox x:Name="txtPRE_PAID" Text="{Binding PrePaid, StringFormat=\{0:###\,##0\}, UpdateSourceTrigger=PropertyChanged}" TextAlignment="Right" Height="30" Width="130" Margin="0,0,0,0" PreviewTextInput="IsAcceptNumberic" Background="#FF0050EF" Foreground="#FFFCFCFC"/>
                </WrapPanel>
            </StackPanel>

            <StackPanel Margin="10">
                <WrapPanel HorizontalAlignment="Right" Margin="0,0,0,10">
                    <Label Width="80" Height="30" Target="{Binding ElementName=txtSumOut}" Content="Tổng t_oa:" Background="#FF0050EF" Foreground="#FFFCFCFC" />
                    <TextBox x:Name="txtSumOut" IsEnabled="False" Text="{Binding SumOut, StringFormat=\{0:###\,##0\} VNĐ, UpdateSourceTrigger=PropertyChanged}" TextAlignment="Right" Height="30" Width="130" Margin="0,0,0,0" Background="#FF0050EF" Foreground="White" />
                </WrapPanel>
                <WrapPanel HorizontalAlignment="Right" Margin="0,0,0,10">
                    <Label Width="80" Height="30" Target="{Binding ElementName=txtTotal}" Content="Tổn_g cộng:" Background="#FF0050EF" Foreground="#FFFCFCFC"/>
                    <TextBox x:Name="txtTotal" IsEnabled="False" Text="{Binding TotalPayment, StringFormat=\{0:###\,##0\} VNĐ, UpdateSourceTrigger=PropertyChanged}" TextAlignment="Right" Height="30" Width="130" Margin="0,0,0,0" Background="#FF0050EF" Foreground="White"/>
                </WrapPanel>
                <WrapPanel HorizontalAlignment="Right">
                    <Label Width="80" Height="30" Target="{Binding ElementName=txtRemain}" Content="Còn _lại:" Background="#FF0050EF" Foreground="White"/>
                    <TextBox x:Name="txtRemain" IsEnabled="False" Text="{Binding Remain, StringFormat=\{0:###\,##0\} VNĐ, UpdateSourceTrigger=PropertyChanged}" TextAlignment="Right" Height="30" Width="130" Margin="0,0,0,0" Background="#FF0050EF" Foreground="White"/>
                </WrapPanel>
            </StackPanel>
        </StackPanel>
        <!-- -->
        <!-- -->
    </StackPanel>
</Window>
